#!/bin/bash
echo -n "Uninstalling app from phone... "; UNINSTALLED=`adb uninstall org.prx.prp`
if [[ $UNINSTALLED == Failure*  ]]; then
    echo "App Not Present!"
else
    echo $UNINSTALLED
fi
echo "Compiling and installing app..."; ant install 2>&1 | awk '/echo/{ print substr($0,13,length($0)-12) }; /javac/{print ">>>  " substr($0,13,length($0)-12)}'
if [[ $? -eq 0 ]]; then
    echo -n "Starting app... " ; adb shell "am start -a android.intent.action.MAIN -n org.prx.prp/.view.SplashActivity" | grep Error> /dev/null
    if [[ $? -ne 0 ]]; then
        echo "Done!"
        if [ z$1 = zlc ]; then
            adb logcat
        elif [ z$1 = zlcp ]; then
            adb logcat | grep PRPAND
        fi
    else
        echo "Error!"
        echo
        echo "There was a problem starting your app..."
        echo "Good Luck!"
    fi
else
    echo ""
    echo "Interrrupted! Will not attempt to start the app..."
    echo "Good Luck!"
fi
